﻿namespace CN2P.ServiceModel
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;

    [DataContract]
    public class ProductReviewModelPagedList
    {
        public ProductReviewModelPagedList(IList<ProductReviewModelResponse> allItems, int pageIndex, int pageSize)
        {
            if (null != allItems)
            {
                this.Reviews = allItems
                    .Skip((pageIndex - 1)*pageSize)
                    .Take(pageSize)
                    .ToList();
                this.TotalCount = allItems.Count;
            }
        }

        [DataMember(Name = "totalCount")]
        public int TotalCount { get; set; }

        [DataMember(Name = "reviews")]
        public IList<ProductReviewModelResponse> Reviews { get; set; }
    }
}